/**
 * Created by Colin3dmax on 16/12/26.
 */

'use strict';

import * as types from '../constants/action-types';

const initState = {
    userInfo:{},
    userSkillDetails:{},
    userDetailMap:{},
};

export default function reducer(state = initState, action) {
    switch (action.type) {
        case types.CLEAN_USER:
            return initState;
        case types.RECEIVE_LOGIN:
            return Object.assign({},state,action.userInfo)
        case types.RECEIVE_SKILL_DETAIL:{
            const userSkillId = action.userSkillId;
            return Object.assign({},state,{
                userSkillDetails:{
                    ...state.userSkillDetails,
                    [userSkillId]:action.skillInfo,
                }
            })
        }
        case types.RECEIVE_USER_DETAIL:{
            const userId = action.userId;
            return Object.assign({},state,{
                userDetailMap:{
                    ...state.userDetailMap,
                    [userId]:action.userDetail,
                }
            })
        }
        default:
            return state;
    }
}

